/**
 * 
 */
package com.bitantenna.player;

import java.util.Observable;
import java.util.Observer;

import com.bitantenna.Spot;



public final class PlayerStatusObserver implements Observer {
	private final Player player;
	private final Spot spot;
	private final ListTableModel producersModel;

	public PlayerStatusObserver(Player player, Spot spot,
			ListTableModel producersModel) {
		this.player = player;
		this.spot = spot;
		this.producersModel = producersModel;
	}

	@Override
	public void update(Observable o, Object arg) {
		player.getLabel_status().setText(""+spot.status());
		
		if (spot.status()==Spot.Status.connecting) {
			spot.onConsume().addObserver(new Observer() {						
				@Override
				public void update(Observable arg0, Object arg1) {
				      producersModel.fireChanges();
				      //System.out.println(spot.radioConsumers.size()+","+spot.radioProducers.size());					  					
				}});
		}

		
	}
}